package com.woniu.goods.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCUtil {
	private Connection conn ;
	
	/**
	 * 返回一个COnneion链接对象
	 * @return
	 * @throws Exception
	 */
	public Connection getConnection() throws Exception{
		/*if(conn != null) {
			return conn ;
		}else {*/
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql:///goodsmanager?useUnicode=true&characterEncoding=UTF8", "root", "123456");
			return conn ;
		//}
	}
	
	public void release(ResultSet rs ,Statement st ,Connection conn) throws SQLException {
		if(rs != null) {
			rs.close();
		}
		if(st != null) {
			st.close();
		}
		if(conn != null) {
			conn.close();
		}
	}
	
	
}
